package cn.net.isir.controller.manager;

import cn.net.isir.common.ResultObject;
import cn.net.isir.core.BasicController;
import cn.net.isir.core.SetBasicService;
import cn.net.isir.entity.GoodsSpecification;
import cn.net.isir.service2.GoodsSpecificationService;
import cn.net.isir.utils.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author liuxubo
 * @filename GoodsController.java
 * @package cn.net.isir.controller.manager
 * @email lxb@isir.net.cn
 * @date 2018/12/04
 * @comment 规格类
 * @since 1.8
 */
@RestController
@RequestMapping("/goodsSpec")
public class GoodsSpecController extends BasicController<GoodsSpecification> {
    @SetBasicService
    @Resource
    private GoodsSpecificationService goodsSpecificationService;

    /**
     * 获取规格列表
     *
     * @param goodsId 参数
     * @return 规格列表
     */
    @RequestMapping(value = "/list/{goodsId}", method = RequestMethod.GET)
    public ResultObject listByGoodsId(@PathVariable String goodsId) {
        if (StringUtils.isBlank(goodsId)) {
            return new ResultObject(500, "goodsId is null", null);
        }
        GoodsSpecification spec = new GoodsSpecification();
        spec.setGoodsId(goodsId);
        return new ResultObject(200, "success", goodsSpecificationService.selectList(spec));
    }

}
